import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'

export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd())

  return {
    plugins: [react()],
    css: {
      preprocessorOptions: {
        less: {
          // Less配置选项
          javascriptEnabled: true,
          modifyVars: {
            // 可以在这里定义全局变量
          }
        }
      }
    },
    server: {
      host: true,
      port: 3000,
      open: true
    },
    build: {
      outDir: 'dist',
      sourcemap: mode !== 'production'
    }
  }
})
